home *** CD-ROM | disk | FTP | other *** search
/ Erotic Games: Memory / Erotic Games: Memory.iso / mac / air_installers / AdobeAIR.exe / setup.swf / scripts / mx / core / RSLItem.as < prev    next >
Text File  |  2009-02-12  |  4KB  |  109 lines

  1. package mx.core
  2. {
  3.    import flash.display.Loader;
  4.    import flash.events.ErrorEvent;
  5.    import flash.events.Event;
  6.    import flash.events.IOErrorEvent;
  7.    import flash.events.ProgressEvent;
  8.    import flash.events.SecurityErrorEvent;
  9.    import flash.net.URLRequest;
  10.    import flash.system.ApplicationDomain;
  11.    import flash.system.LoaderContext;
  12.    import mx.events.RSLEvent;
  13.    
  14.    use namespace mx_internal;
  15.    
  16.    public class RSLItem
  17.    {
  18.       
  19.       mx_internal static const VERSION:String = "3.0.0.0";
  20.        
  21.       
  22.       protected var chainedSecurityErrorHandler:Function;
  23.       
  24.       public var total:uint = 0;
  25.       
  26.       public var loaded:uint = 0;
  27.       
  28.       private var completed:Boolean = false;
  29.       
  30.       protected var chainedRSLErrorHandler:Function;
  31.       
  32.       protected var chainedIOErrorHandler:Function;
  33.       
  34.       protected var chainedCompleteHandler:Function;
  35.       
  36.       private var errorText:String;
  37.       
  38.       protected var chainedProgressHandler:Function;
  39.       
  40.       public var urlRequest:URLRequest;
  41.       
  42.       protected var url:String;
  43.       
  44.       public function RSLItem(param1:String)
  45.       {
  46.          super();
  47.          this.url = param1;
  48.       }
  49.       
  50.       public function itemProgressHandler(param1:ProgressEvent) : void
  51.       {
  52.          loaded = param1.bytesLoaded;
  53.          total = param1.bytesTotal;
  54.          if(chainedProgressHandler != null)
  55.          {
  56.             chainedProgressHandler(param1);
  57.          }
  58.       }
  59.       
  60.       public function itemErrorHandler(param1:ErrorEvent) : void
  61.       {
  62.          errorText = decodeURI(param1.text);
  63.          completed = true;
  64.          loaded = 0;
  65.          total = 0;
  66.          trace(errorText);
  67.          if(param1.type == IOErrorEvent.IO_ERROR && chainedIOErrorHandler != null)
  68.          {
  69.             chainedIOErrorHandler(param1);
  70.          }
  71.          else if(param1.type == SecurityErrorEvent.SECURITY_ERROR && chainedSecurityErrorHandler != null)
  72.          {
  73.             chainedSecurityErrorHandler(param1);
  74.          }
  75.          else if(param1.type == RSLEvent.RSL_ERROR && chainedRSLErrorHandler != null)
  76.          {
  77.             chainedRSLErrorHandler(param1);
  78.          }
  79.       }
  80.       
  81.       public function load(param1:Function, param2:Function, param3:Function, param4:Function, param5:Function) : void
  82.       {
  83.          chainedProgressHandler = param1;
  84.          chainedCompleteHandler = param2;
  85.          chainedIOErrorHandler = param3;
  86.          chainedSecurityErrorHandler = param4;
  87.          chainedRSLErrorHandler = param5;
  88.          var _loc6_:Loader = new Loader();
  89.          var _loc7_:LoaderContext = new LoaderContext();
  90.          urlRequest = new URLRequest(url);
  91.          _loc6_.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,itemProgressHandler);
  92.          _loc6_.contentLoaderInfo.addEventListener(Event.COMPLETE,itemCompleteHandler);
  93.          _loc6_.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,itemErrorHandler);
  94.          _loc6_.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR,itemErrorHandler);
  95.          _loc7_.applicationDomain = ApplicationDomain.currentDomain;
  96.          _loc6_.load(urlRequest,_loc7_);
  97.       }
  98.       
  99.       public function itemCompleteHandler(param1:Event) : void
  100.       {
  101.          completed = true;
  102.          if(chainedCompleteHandler != null)
  103.          {
  104.             chainedCompleteHandler(param1);
  105.          }
  106.       }
  107.    }
  108. }
  109.